﻿using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Sustainalytics.DynamicsCRMGateway.Entities;
using System.Linq;

[assembly: ProxyTypesAssemblyAttribute()]

namespace Sustainalytics.DynamicsCRMGateway
{
    /// <summary>
    /// Represents a source of entities bound to a CRM service. It tracks and manages changes made to the retrieved entities.
    /// Entities were genrated using the CRM Early Bound Generator found here https://xrmearlyboundgenerator.codeplex.com/
    /// </summary>
    public class CrmServiceContext : CrmOrganizationServiceContext, ICrmServiceContext
    {
        internal CrmServiceContext()
        {
        }

        internal CrmServiceContext(CrmConnection connection) :
            base(connection)
        {
        }

        internal CrmServiceContext(string contextName) :
            base(contextName)
        {
        }

        internal CrmServiceContext(IOrganizationService service) :
            base(service)
        {
        }

        public void ClearCache()
        {
            this.ClearChanges();
        }

        public IQueryable<Account> AccountSet
        {
            get { return this.CreateQuery<Account>(); }
        }

        public IQueryable<AccountFeature> AccountFeatureSet
        {
            get { return this.CreateQuery<AccountFeature>(); }
        }

        public IQueryable<AccountUniverse> AccountUniverseSet
        {
            get { return this.CreateQuery<AccountUniverse>(); }
        }

        public IQueryable<Claim> ClaimSet
        {
            get { return this.CreateQuery<Claim>(); }
        }

        public IQueryable<CompaniesGroup> CompaniesGroupSet
        {
            get { return this.CreateQuery<CompaniesGroup>(); }
        }

        public IQueryable<CompaniesGroupConstituent> CompaniesGroupConstituentSet
        {
            get { return this.CreateQuery<CompaniesGroupConstituent>(); }
        }

        public IQueryable<Company> CompanySet
        {
            get { return this.CreateQuery<Company>(); }
        }

        public IQueryable<Feature> FeatureSet
        {
            get { return this.CreateQuery<Feature>(); }
        }

        public IQueryable<CompaniesGroupAccountUniverseBridge> CompaniesGroupAccountUniverseBridgeSet
        {
            get { return this.CreateQuery<CompaniesGroupAccountUniverseBridge>(); }
        }

        public IQueryable<FeatureClaimBridge> FeatureClaimBridgeSet
        {
            get { return this.CreateQuery<FeatureClaimBridge>(); }
        }

        public IQueryable<UniverseFeatureProductUniverseBridge> UniverseFeatureProductUniverseBridgeSet
        {
            get { return this.CreateQuery<UniverseFeatureProductUniverseBridge>(); }
        }

        public IQueryable<ProductUniverse> ProductUniverseSet
        {
            get { return this.CreateQuery<ProductUniverse>(); }
        }

        public IQueryable<UniverseFeature> UniverseFeatureSet
        {
            get { return this.CreateQuery<UniverseFeature>(); }
        }
    }
}